﻿// Version:1
// Author:Sanket Naik
// Date:July-21-2010 
// Comments:
// 
// 
// 

using System;
using System.Linq;
using System.Data.Linq;
using System.Data.Linq.Mapping;
using System.Runtime.Serialization;
using ManagedServices.Common.DataTransferObject;
using System.ComponentModel;

namespace ManagedServices.DataTransferObjects
{

    /// <summary>
    /// The table representing the Message BUS which is focal to the idea of inter communication of sub services
    /// </summary>
    [DataContract]
    [global::System.Data.Linq.Mapping.TableAttribute(Name = "dbo.Msf_Tbl_MessageStore")]
    public partial class MessageStore : INotifyPropertyChanging, INotifyPropertyChanged, ICommonDto
    {

        private static PropertyChangingEventArgs emptyChangingEventArgs = new PropertyChangingEventArgs(String.Empty);

        private System.Guid _Msf_Col_MessageID;

        private string _Msf_Col_MessageRootElement;

        private string _Msf_Col_MessageNamespace;

        private string _Msf_Col_MessagePayload;

        private short _Msf_Col_MessageState;

        private System.Guid _Msf_Col_CreatedBy;

        private System.Nullable<System.Guid> _Msf_Col_ModifiedBy;

        private System.DateTime _Msf_Col_CreatedOn;

        private System.Nullable<System.DateTime> _Msf_Col_ModifiedOn;

        #region Extensibility Method Definitions
        partial void OnLoaded();
        partial void OnValidate(System.Data.Linq.ChangeAction action);
        partial void OnCreated();
        partial void OnMessageIDChanging(System.Guid value);
        partial void OnMessageIDChanged();
        partial void OnMessageRootElementChanging(string value);
        partial void OnMessageRootElementChanged();
        partial void OnMessageNamespaceChanging(string value);
        partial void OnMessageNamespaceChanged();
        partial void OnMessagePayloadChanging(string value);
        partial void OnMessagePayloadChanged();
        partial void OnMessageStateChanging(short value);
        partial void OnMessageStateChanged();
        partial void OnCreatedByChanging(System.Guid value);
        partial void OnCreatedByChanged();
        partial void OnModifiedByChanging(System.Nullable<System.Guid> value);
        partial void OnModifiedByChanged();
        partial void OnCreatedOnChanging(System.DateTime value);
        partial void OnCreatedOnChanged();
        partial void OnModifiedOnChanging(System.Nullable<System.DateTime> value);
        partial void OnModifiedOnChanged();
        #endregion

        public MessageStore()
        {
            OnCreated();
        }

        /// <summary>
        /// The Guid that uniquely identifies the Message Instance
        /// </summary>
        [DataMember]
        [global::System.Data.Linq.Mapping.ColumnAttribute(Name = "Msf_Col_MessageID", Storage = "_Msf_Col_MessageID", DbType = "UniqueIdentifier NOT NULL", IsPrimaryKey = true)]
        public System.Guid MessageID
        {
            get
            {
                return this._Msf_Col_MessageID;
            }
            set
            {
                if ((this._Msf_Col_MessageID != value))
                {
                    this.OnMessageIDChanging(value);
                    this.SendPropertyChanging();
                    this._Msf_Col_MessageID = value;
                    this.SendPropertyChanged("MessageID");
                    this.OnMessageIDChanged();
                }
            }
        }

        /// <summary>
        /// The Root element of the Message
        /// </summary>
        [DataMember]
        [global::System.Data.Linq.Mapping.ColumnAttribute(Name = "Msf_Col_MessageRootElement", Storage = "_Msf_Col_MessageRootElement", DbType = "NVarChar(250) NOT NULL", CanBeNull = false)]
        public string MessageRootElement
        {
            get
            {
                return this._Msf_Col_MessageRootElement;
            }
            set
            {
                if ((this._Msf_Col_MessageRootElement != value))
                {
                    this.OnMessageRootElementChanging(value);
                    this.SendPropertyChanging();
                    this._Msf_Col_MessageRootElement = value;
                    this.SendPropertyChanged("MessageRootElement");
                    this.OnMessageRootElementChanged();
                }
            }
        }

        /// <summary>
        /// The namespace of the Message         
        /// </summary>
        [DataMember]
        [global::System.Data.Linq.Mapping.ColumnAttribute(Name = "Msf_Col_MessageNamespace", Storage = "_Msf_Col_MessageNamespace", DbType = "NVarChar(500) NOT NULL", CanBeNull = false)]
        public string MessageNamespace
        {
            get
            {
                return this._Msf_Col_MessageNamespace;
            }
            set
            {
                if ((this._Msf_Col_MessageNamespace != value))
                {
                    this.OnMessageNamespaceChanging(value);
                    this.SendPropertyChanging();
                    this._Msf_Col_MessageNamespace = value;
                    this.SendPropertyChanged("MessageNamespace");
                    this.OnMessageNamespaceChanged();
                }
            }
        }

        /// <summary>
        /// The payload of the Message 
        /// </summary>
        [DataMember]
        [global::System.Data.Linq.Mapping.ColumnAttribute(Name="Msf_Col_MessagePayload", Storage = "_Msf_Col_MessagePayload", DbType = "NVarChar(MAX) NOT NULL", CanBeNull = false)]
        public string MessagePayload
        {
            get
            {
                return this._Msf_Col_MessagePayload;
            }
            set
            {
                if ((this._Msf_Col_MessagePayload != value))
                {
                    this.OnMessagePayloadChanging(value);
                    this.SendPropertyChanging();
                    this._Msf_Col_MessagePayload = value;
                    this.SendPropertyChanged("MessagePayload");
                    this.OnMessagePayloadChanged();
                }
            }
        }

        /// <summary>
        /// The State of the Message 
        /// </summary>
        [global::System.Data.Linq.Mapping.ColumnAttribute(Name="Msf_Col_MessageState", Storage = "_Msf_Col_MessageState", DbType = "SmallInt NOT NULL")]
        public short Msf_Col_MessageState
        {
            get
            {
                return this._Msf_Col_MessageState;
            }
            set
            {
                if ((this._Msf_Col_MessageState != value))
                {
                    this.OnMessageStateChanging(value);
                    this.SendPropertyChanging();
                    this._Msf_Col_MessageState = value;
                    this.SendPropertyChanged("MessageState");
                    this.OnMessageStateChanged();
                }
            }
        }

        /// <summary>
        /// Primary key for the DTO
        /// </summary>
        public Guid KeyId { get { return MessageID; } set { MessageID = value; } }

        /// <summary>
        /// Created By
        /// </summary>
        [DataMember]
        [global::System.Data.Linq.Mapping.ColumnAttribute(Name = "Msf_Col_CreatedBy", Storage = "_Msf_Col_CreatedBy", DbType = "UniqueIdentifier NOT NULL")]
        public System.Guid CreatedBy
        {
            get
            {
                return this._Msf_Col_CreatedBy;
            }
            set
            {
                if ((this._Msf_Col_CreatedBy != value))
                {
                    this.OnCreatedByChanging(value);
                    this.SendPropertyChanging();
                    this._Msf_Col_CreatedBy = value;
                    this.SendPropertyChanged("CreatedBy");
                    this.OnCreatedByChanged();
                }
            }
        }

        /// <summary>
        /// Modified By
        /// </summary>
        [DataMember]
        [global::System.Data.Linq.Mapping.ColumnAttribute(Name = "Msf_Col_ModifiedBy", Storage = "_Msf_Col_ModifiedBy", DbType = "UniqueIdentifier")]
        public System.Nullable<System.Guid> ModifiedBy
        {
            get
            {
                return this._Msf_Col_ModifiedBy;
            }
            set
            {
                if ((this._Msf_Col_ModifiedBy != value))
                {
                    this.OnModifiedByChanging(value);
                    this.SendPropertyChanging();
                    this._Msf_Col_ModifiedBy = value;
                    this.SendPropertyChanged("ModifiedBy");
                    this.OnModifiedByChanged();
                }
            }
        }

        /// <summary>
        /// Created On
        /// </summary>
        [DataMember]
        [global::System.Data.Linq.Mapping.ColumnAttribute(Name = "Msf_Col_CreatedOn", Storage = "_Msf_Col_CreatedOn", DbType = "DateTime NOT NULL")]
        public System.DateTime CreatedOn
        {
            get
            {
                return this._Msf_Col_CreatedOn;
            }
            set
            {
                if ((this._Msf_Col_CreatedOn != value))
                {
                    this.OnCreatedOnChanging(value);
                    this.SendPropertyChanging();
                    this._Msf_Col_CreatedOn = value;
                    this.SendPropertyChanged("CreatedOn");
                    this.OnCreatedOnChanged();
                }
            }
        }

        /// <summary>
        /// Modified On
        /// </summary>
        [DataMember]
        [global::System.Data.Linq.Mapping.ColumnAttribute(Name = "Msf_Col_ModifiedOn", Storage = "_Msf_Col_ModifiedOn", DbType = "DateTime")]
        public System.Nullable<System.DateTime> ModifiedOn
        {
            get
            {
                return this._Msf_Col_ModifiedOn;
            }
            set
            {
                if ((this._Msf_Col_ModifiedOn != value))
                {
                    this.OnModifiedOnChanging(value);
                    this.SendPropertyChanging();
                    this._Msf_Col_ModifiedOn = value;
                    this.SendPropertyChanged("ModifiedOn");
                    this.OnModifiedOnChanged();
                }
            }
        }
        
        public event PropertyChangingEventHandler PropertyChanging;

        public event PropertyChangedEventHandler PropertyChanged;

        protected virtual void SendPropertyChanging()
        {
            if ((this.PropertyChanging != null))
            {
                this.PropertyChanging(this, emptyChangingEventArgs);
            }
        }

        protected virtual void SendPropertyChanged(String propertyName)
        {
            if ((this.PropertyChanged != null))
            {
                this.PropertyChanged(this, new PropertyChangedEventArgs(propertyName));
            }
        }
    }

}
